package ch.rheintalconnection.sysventory.presentation.panels;



import ch.rheintalconnection.sysventory.presentation.MainApplicationHandler;

import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.VerticalLayout;

public class MenuPanel extends VerticalLayout implements Button.ClickListener{

	private static final long serialVersionUID = -2235140722796049860L;
	
	private ContentPanel contentPanel;
	private MainApplicationHandler mainApphHandler;
		
	public MenuPanel(ContentPanel contentPanel, MainApplicationHandler mainApphHandler){
		this.contentPanel = contentPanel;
		this.mainApphHandler = mainApphHandler;
		createButtons();
	}

	private void createButtons(){
		Button btnScan = new Button("Scan");
		btnScan.addListener(this);
		this.addComponent(btnScan);
		Button btnComputer = new Button("Suchen");
		btnComputer.addListener(this);
		this.addComponent(btnComputer);
		Button btnStatistic = new Button("Statistik");
		btnStatistic.addListener(this);
		this.addComponent(btnStatistic);
		Button btnLogout = new Button("Logout");
		btnLogout.addListener(this);
		this.addComponent(btnLogout);
	}

	public void buttonClick(ClickEvent event) {
		String sButtonCaption = event.getButton().getCaption();
		
		if(sButtonCaption.equals("Scan")){
			contentPanel.activateScanPanel();
		}else if(sButtonCaption.equals("Suchen")){
			contentPanel.activateScannedComputersPanel();
		}else if(sButtonCaption.equals("Statistik")){
			contentPanel.activateStatisticPanel();
		}else if (sButtonCaption.equals("Logout")) {
			mainApphHandler.activateLoginPanel();
	
		}
		
	}
	
}
